//
//  AXFOrderTableViewCell.m
//  MineOrderUI
//
//  Created by mac2 on 16/11/24.
//  Copyright © 2016年 mac2. All rights reserved.
//

#import "AXFOrderTableViewCell.h"
#import "CZAdditions.h"
#import "Masonry.h"
@implementation AXFOrderTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
//    [self setupUI];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    //1.头部灰色的VIew
    UIView *headGrayView = [[UIView alloc]init];
    headGrayView.backgroundColor = [UIColor cz_colorWithHex:0xefefef];
    
    //2.时间label
    UILabel *timeLabel = [[UILabel alloc]init];
    timeLabel.text = @"2016-11-24 14:40:39";
    timeLabel.font = [UIFont systemFontOfSize:12];
    //3待支付
    UILabel *waiPay = [[UILabel alloc]init];
    waiPay.text = @"待支付";
    waiPay.font = [UIFont systemFontOfSize:15];
    [waiPay setTextColor:[UIColor redColor]];
    //4分界线
    UIView *line1 = [[UIView alloc]init];
    line1.backgroundColor = [UIColor cz_colorWithHex:0xe8e8e8];
    //5.5个图片View
    UIView *image1 = [[UIView alloc]init];
    image1.backgroundColor = [UIColor blueColor];
    //6.箭头View
    UIImageView *jiantouImageView = [[UIImageView alloc]init];
    jiantouImageView.image = [UIImage imageNamed:@"icon_go"];
    //7.分界线2
    UIView * lin2 = [[UIView alloc]init];
    lin2.backgroundColor = [UIColor cz_colorWithHex:0xe8e8e8];
    //8.商品数量 价格Label
    UILabel *goodsCount = [[UILabel alloc]init];
    goodsCount.text = @"共3件商品  实付:￥20.9";
    goodsCount.font = [UIFont systemFontOfSize:14];
    //9.分界线
    UIView *line3 = [[UIView alloc]init];
    line3.backgroundColor = [UIColor cz_colorWithHex:0xe8e8e8];
    //10.去支付按钮
    UIButton *payButton = [[UIButton alloc]init];
    [payButton setTitle:@"去支付" forState:UIControlStateNormal];
    payButton.titleLabel.font = [UIFont systemFontOfSize:13];
    [payButton.layer setMasksToBounds:YES];
    [payButton.layer setCornerRadius:5.0];
    payButton.backgroundColor = [UIColor cz_colorWithHex:0xffd700];
    
    //添加
    [self.contentView addSubview:headGrayView];
    [self.contentView addSubview:timeLabel];
    [self.contentView addSubview:waiPay];
    [self.contentView addSubview:line1];
    [self.contentView addSubview:image1];
    
    [self.contentView addSubview:jiantouImageView];
    [self.contentView addSubview:lin2];
    [self.contentView addSubview:goodsCount];
    [self.contentView addSubview:line3];
    [self.contentView addSubview:payButton];
    
    //约束
    [headGrayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.contentView);
        make.height.equalTo(@24);
    }];
    
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headGrayView.mas_bottom).offset(12);
        make.left.equalTo(self.contentView).offset(10);
        make.width.equalTo(@145);
        make.height.equalTo(@13);
    }];
    [waiPay mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(timeLabel);
        make.right.equalTo(self.contentView).offset(-10);
        make.height.equalTo(@15);
    }];
    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(waiPay.mas_bottom).offset(9);
        make.left.equalTo(self.contentView).offset(10);
        make.right.equalTo(self.contentView);
        make.height.equalTo(@1);
    }];
    [image1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(line1);
        make.top.equalTo(line1).offset(6);
        make.width.height.equalTo(@60);
    }];
     [jiantouImageView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.right.equalTo(self.contentView).offset(-10);
         make.centerY.equalTo(image1);
         make.width.height.equalTo(@10);
     }];
    [lin2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(image1.mas_bottom).offset(6);
        make.left.right.height.equalTo(line1);
    }];
    
    [goodsCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-10);
        make.top.equalTo(lin2).offset(9);
        make.height.equalTo(@14);
    }];
    [line3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(goodsCount.mas_bottom).offset(9);
        make.left.right.height.equalTo(lin2);
    }];
    [payButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-10);
        make.top.equalTo(line3.mas_bottom).offset(6);
        make.height.equalTo(@27);
        make.width.equalTo(@75);
    }];
    
}








- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
























